import 'package:flutter/material.dart';
import 'package:top_foundation/top_foundation.dart';

import 'index.dart';
import 'widgets/cell.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);
  final controller = Get.put(HomeController());
  // 主视图
  Widget _buildView() {
    var state = controller.state;
    return PlanedListView(
      itemCount: (section) => state.list?.length ?? 0,
      itemBuilder: (section, item) {
        var md = state.list![item];
        return HomeCell(itemKey: md.key, mod: md);
      },
      sectionBuilder: (context, index) {
        return Container(
          child: TextField(),
        );
      },
      sectionHeight: (section) => 60,
      header: Container(),
      footer: Container(),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("示例")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
